import argparse
from prefect import flow

from task import (
    connect_to_neo4j,
    get_config_from_secret_block_as_json,
)


@flow(log_prints=True)
def neo4j_connect_flow(target: str):
    """
    Given a neo4j aura instance, test connectivity.
    """
    print(f"target:{target}")
    print("use remote from secret block")
    config = get_config_from_secret_block_as_json(target) if target is not None else {}
    # print(f"config:{config}")
    connect_to_neo4j(target=target, **config)

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("target")
    args = parser.parse_args()
    # print("args:", args)
    neo4j_connect_flow(**vars(args))
